package fms.iwantsomemoney;

import com.google.gson.Gson;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.URL;
import java.net.URLConnection;
import java.util.ArrayList;

public class GuildWars2ApiAccess {
    private static final String LISTINGS_URL = "https://api.guildwars2.com/v2/commerce/listings/";

    public static ArrayList<String> retrieveListings(String itemId) throws IOException {
        URL url = new URL(LISTINGS_URL + itemId);

        URLConnection oc = url.openConnection();
        BufferedReader br = new BufferedReader(new InputStreamReader(oc.getInputStream()));

        String line;
        ArrayList<String> result = new ArrayList<>();
        while ((line = br.readLine()) != null) {
            result.add(line);
        }

        return result;
    }
}